package com.example.frickytest;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;
import android.app.Activity;
import android.view.Menu;

public class PictureActivity extends Activity {

	private Gallery gallery;
	private ImageView imageview;
	private myImageAdapter imageadapter;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_picture);

		imageadapter = new myImageAdapter(this);

		gallery = (Gallery) findViewById(R.id.Gallery_preView);
		imageview = (ImageView) findViewById(R.id.ImageView_photo);

		gallery.setAdapter(imageadapter);

		gallery.setOnItemClickListener(new Gallery.OnItemClickListener() {

			public void onItemClick(AdapterView<?> parent, View v,
					int position, long id) {

				Toast.makeText(PictureActivity.this, "这是图片：" + position + "号",
						Toast.LENGTH_SHORT).show();

				imageview
						.setBackgroundResource(imageadapter.myImageIds[position]);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_picture, menu);
		return true;
	}
}
